package com.ruoyi.web.controller.banner.admin;


import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.category.service.IWebCarouselService;
import com.ruoyi.model.banner.WebCarousel;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * aaaController
 *
 * @author ruoyi
 * @date 2024-08-03
 */
@RestController
@RequestMapping("/web/carousel")
public class WebCarouselController extends BaseController
{
    @Autowired
    private IWebCarouselService webCarouselService;

    /**
     * 查询aaa列表
     */
    @PreAuthorize("@ss.hasPermi('system:carousel:list')")
    @GetMapping("/list")
    public TableDataInfo list(WebCarousel webCarousel)
    {
        startPage();
        List<WebCarousel> list = webCarouselService.selectWebCarouselList(webCarousel);
        return getDataTable(list);
    }

    /**
     * 导出aaa列表
     */
    @PreAuthorize("@ss.hasPermi('system:carousel:export')")
    @Log(title = "aaa", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WebCarousel webCarousel)
    {
        List<WebCarousel> list = webCarouselService.selectWebCarouselList(webCarousel);
        ExcelUtil<WebCarousel> util = new ExcelUtil<WebCarousel>(WebCarousel.class);
        util.exportExcel(response, list, "aaa数据");
    }

    /**
     * 获取aaa详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:carousel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(webCarouselService.selectWebCarouselById(id));
    }

    /**
     * 新增aaa
     */
    @PreAuthorize("@ss.hasPermi('system:carousel:add')")
    @Log(title = "aaa", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WebCarousel webCarousel)
    {
        return toAjax(webCarouselService.insertWebCarousel(webCarousel));
    }

    /**
     * 修改aaa
     */
    @PreAuthorize("@ss.hasPermi('system:carousel:edit')")
    @Log(title = "aaa", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WebCarousel webCarousel)
    {
        return toAjax(webCarouselService.updateWebCarousel(webCarousel));
    }

    /**
     * 删除aaa
     */
    @PreAuthorize("@ss.hasPermi('system:carousel:remove')")
    @Log(title = "aaa", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(webCarouselService.deleteWebCarouselByIds(ids));
    }
}

